#!/bin/bash

PYCMD=python

if command -v python3 > /dev/null
then
    PYCMD=python3
fi

lowercase() {
    echo "$1" | awk '{ print tolower($0); }'
}

OS=`lowercase \`uname\``

if [ "$OS" == "darwin" ]; then
    realpath() {
        OURPWD=$PWD
        cd "$(dirname "$1")"
        LINK=$(readlink "$(basename "$1")")
        while [ "$LINK" ]; do
        cd "$(dirname "$LINK")"
        LINK=$(readlink "$(basename "$1")")
        done
        REALPATH="$PWD/$(basename "$1")"
        cd "$OURPWD"
        echo "$REALPATH"
    }
fi

"$PYCMD" "$(realpath "$(dirname "${BASH_SOURCE[0]}")")"/run.py "$@"
